<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点击获取段子</button>

    <script>
        //获取按钮
        let btn = document.querySelector('button');

        //绑定事件
        btn.onclick = function(){
            //fetch 是浏览器的全局函数, 用来发送 AJAX 请求
            fetch('http://api.xiaohigh.com/duanzi')
            .then(res => {
                return res.json();
            }).then(res => {
                console.log(res);
            })
        }

    </script>
</body>
</html>